#ifndef ALERTMANAGER_H
#define ALERTMANAGER_H

#include <QMainWindow>
#include "../MainProject/sqlitedatabase.h"
//#include <QSqlTableModel>
#include <QStandardItemModel>
#include <QTimer>
#include "../MainProject/loggermanager.h"
#include "../MainProject/common.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class AlertManager;
}
QT_END_NAMESPACE

class AlertManager : public QMainWindow
{
    Q_OBJECT

public:
    AlertManager(QWidget *parent = nullptr);
    ~AlertManager();

    void setupModel();
    void setupConnections();

    void triggerAlert(int deviceId, const QString &content);
    void sendNotification(int deviceId, const QString &deviceName, const QString &content, const QString &timestamp);


public slots:
    void onAddAlertRule();
    void onEditAlertRule();
    void onDeleteAlertRule();
    void checkAlerts();
    void onBatchDeleteAlertRules();
    void ReceiveLogininformation(QString &userName,QString &role);

private:
    Ui::AlertManager *ui;
    QStandardItemModel *model;
    SQLiteDatabase* db;
    QTimer *alertTimer;
    Common common;
};

#endif // ALERTMANAGER_H
